package com.zhiyou100.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhiyou100.mapper.UserMapper;
import com.zhiyou100.model.Result;
import com.zhiyou100.model.User;
import com.zhiyou100.service.UserService;

@Service
public class UserServiceImpl implements UserService{

	@Autowired
	private UserMapper userMapper;
	public UserMapper getUserMapper() {
		return userMapper;
	}
	public void setUserMapper(UserMapper userMapper) {
		this.userMapper = userMapper;
	}

	@Override
	public Result insertUser(User user) {
		int i = userMapper.insertUser(user);
		Result result = new Result(false, "新增user失败");
		if(i>0){
			result.setFlag(true);
			result.setMessage("新增user成功");
		}
		return result;
	}
	@Override
	public User selectUserById(int id) {
		
		return userMapper.selectById(id);
	}
	@Override
	public Result updateUserById(User user) {
		int i = userMapper.updateUserById(user);
		Result result = new Result(false, "修改user失败");
		if(i>0){
			result.setFlag(true);
			result.setMessage("修改user成功");
		}
		return result;
	}

}
